<?php

namespace app\admin\controller;

use app\common\controller\Send;
use app\admin\model\OauthFocus AS FocusModel;
use app\common\enums\StatusEnum;

class OauthFocus extends Base
{
    use Send;

    public function index()
    {
        $search = input('');
        $oauthId = isset($search['oauth_id']) ? $search['oauth_id'] : 0;
        $nickname = isset($search['nickname']) ? $search['nickname'] : '';
        $search = [
            'oauth_id' => $oauthId,
            'nickname' => $nickname,
        ];

        $where = [];
        if ($search['nickname']) {
            $where[] = ['o.nickname', 'like', '%' . $search['nickname'] . '%'];
        }

        if ($search['oauth_id']) {
            $where[] = ['f.oauth_id', '=', $search['oauth_id']];
        }

        $model = FocusModel::getList($where);
        return view('index', [
            'model' => $model['model'],
            'count' => $model['count'],
            'search' => $search,
            'status' => StatusEnum::$listExplain,
            'cancelUrl' => url('index', ['oauth_id' => $search['oauth_id']])
        ]);
    }
}
